<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/7/19
 * Time: 14:12
 */

namespace Modules\Admin\Service;


class TemplateService
{
	public function getAllTemplate(){
		$glob=glob(public_path ('templates').'/*');
		$temp=[];
		foreach($glob as $v){
			$file=$v.'/package.json';
			$dir=basename ($v);
			if(is_file ($file)){
				$content=json_decode (file_get_contents ($file),true);
				$content['name']=$dir;
				$content['url']=asset ('templates/'.$dir.'/'.$content['preview']);
				$temp[]=$content;
			}
		}
		return $temp;
	}
}